package net.xiaoyu233.mitemod.miteite.util;

import net.minecraft.World;
import net.xiaoyu233.mitemod.miteite.network.PacketParticle;

public class ParticleUtils {
    public static void spawnParticle(World world, int type, double x, double y, double z, double p1, double p2, double p3) {
        if (!world.isRemote) { // 服务端执行
            PacketParticle packet = new PacketParticle(type, x, y, z, p1,  p2, p3);
            PlayerUtils.sendToAllTrackingPlayers(world, (int) x, (int) z, packet);
        }
    }
    public static void spawblood(World world, int type, double x, double y, double z,int blockid ,int entity){
        if (!world.isRemote) { // 服务端执行
            PacketParticle packet = new PacketParticle(type, x, y, z, blockid,entity);
            PlayerUtils.sendToAllTrackingPlayers(world, (int) x, (int) z, packet);
        }
    }

    public static void spawnParticleLine(World world,
                                         double x1, double y1, double z1,
                                         double x2, double y2, double z2,
                                         int type, int density, double p1, double p2, double p3) {
        for (int i = 0; i <= density; i++) {
            double ratio = (double) i / density;
            double dx = x1 + (x2 - x1) * ratio;
            double dy = y1 + (y2 - y1) * ratio;
            double dz = z1 + (z2 - z1) * ratio;
            spawnParticle(world, type, dx, dy, dz, p1,  p2, p3);
        }
    }

}
